<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Personal_info extends CI_Model
{
	private $users_table_name	= 'users';
	private $user_profiles_table_name	= 'user_profiles';
	
	function __construct()
	{
		parent::__construct();
		$ci =& get_instance();
	}
	
	function update_profile($data,$user_id){
		
		$this->db->set('u.username',$data['username']);
		$this->db->set('u.email',$data['email']);
		
		$this->db->set('up.user_birthdate',$data['user_birthdate']);
		$this->db->set('up.user_sex',$data['user_sex']);
		$this->db->set('up.user_phone',$data['user_phone']);
		$this->db->set('up.user_address',$data['user_address']);
		$this->db->set('up.country',$data['country']);
		$this->db->set('up.city',$data['city']);
		
		$this->db->where('up.user_id',$user_id);
		$this->db->where('u.id = '.'up.user_id');
		$this->db->update($this->users_table_name.' as u, '.$this->user_profiles_table_name.' as up');
		if($this->db->_error_message()){ // no update errors
			return false;
		}
		else{
			return true;	
		}
	}
	
}
